package day1103.demo02;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-03 09:36
 **/
public class Test02 {
    public static void main(String[] args) {
        //无需参数类型
        Operator o = arr -> {
            int sum = 0;
            for (int b : arr) {
                sum += b;
            }
            return sum;
        };


        fun(o);
    }

    public static void fun(Operator operator) {
        int sum[] = {11, 12, 13, 14};
        int sum1 = operator.getSum(sum);
        System.out.println("数组中元素的和:" + sum1);
    }
}

interface Operator {
    //求数组中元素的和
    public int getSum(int[] arr);
}